import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:share_fit/app/components/back_btn_icon.dart';
import 'package:share_fit/app/helper/ext/tr_ext.dart';
import 'package:share_fit/app/tools/color_const.dart';
import 'package:share_fit/generated/locales.g.dart';

import 'light_logic.dart';

class LightPage extends StatelessWidget {
  LightPage({Key? key}) : super(key: key);

  final logic = Get.put(LightLogic());
  final state = Get.find<LightLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(LocaleKeys.light_lift.ts, style: TextStyle(fontSize: 54.sp, color: ColorConst.btnFontColor),),
        centerTitle: true,
        leading: BackBtnIcon(onTap: () => Get.back()),
        // leading: IconButton(
        //   padding: const EdgeInsets.only(left: 15,),
        //   icon: Image.asset("assets/images/space/icon_appbar_arrow_back.png"),
        //   onPressed: () { Get.back(); },
        //   // child: Image.asset("images/icon_appbar_arrow_back.png"),
        // ),
        // leadingWidth: 25,
      ),
      body: Column(
        children: [
          Container(height: 99.h,),
          Image(
            width: 782.w,
            height: 290.h,
            image: const AssetImage("assets/images/device/icon_light_view_top.png"),),
          Container(
            margin: EdgeInsets.fromLTRB(42.w, 100.h, 42.w, 0),
            padding: EdgeInsets.fromLTRB(60.w, 64.h, 36.w, 64.h),
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(10),
                color: Colors.white
            ),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                GetBuilder<LightLogic>(
                    id: 'light_switch',
                    builder: (value) {
                      return Text(state.lightSwitchValue?LocaleKeys.call_remind_on.ts:LocaleKeys.call_remind_off.ts, style: TextStyle(fontSize: 42.sp, color: ColorConst.btnFontColor),);
                    }),
                GetBuilder<LightLogic>(
                    id: 'light_switch',
                    builder: (value) {
                      return Transform.scale(
                          scale: 0.7,
                        child: CupertinoSwitch(value: state.lightSwitchValue, activeColor: ColorConst.activeColor,
                            onChanged: (value) {
                              logic.onSetLightRemindEnable(value);
                            }),);
                    })
              ],),
          ),
        ],
      ),
    );
  }
}
